package model;

public class File {
	private int id;
	private int originalSize;
	private int downloadedSize;
	
	public File(int id, int originalSize, boolean downloaded) {
		setId(id);
		setOriginalSize(originalSize);
		if(downloaded) {
			setDownloadedSize(originalSize);
		} else {
			setDownloadedSize(0);
		}
	}
		
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getOriginalSize() {
		return originalSize;
	}
	public void setOriginalSize(int originalSize) {
		this.originalSize = originalSize;
	}
	public int getDownloadedSize() {
		return downloadedSize;
	}
	
	public void setDownloadedSize(int downloadedSize) {
		this.downloadedSize = downloadedSize;
	}
	
	public boolean isDownloaded() {
		return downloadedSize >= originalSize;
	}
	
	public void setDownloaded() {
		downloadedSize = originalSize;
	}

    public boolean equals(File file) {
        return this.id == file.getId();
    }

    public String toString() {
		return "File: "+id+"-"+originalSize+"-"+downloadedSize;
	}
	
	public File clone() {
		return new File(id, originalSize, isDownloaded());
	}
}
